package fr.skolian.view.tools
{
	import com.greensock.TweenMax;
	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.filters.DropShadowFilter;
	import flash.geom.Rectangle;
	
	import fr.skolian.skins.CloseButtonSkin;
	import fr.skolian.view.arborescence.Arborescence;
	import fr.skolian.view.tools.ui.OtherButton;
	import fr.skolian.view.tools.ui.ScreenShotButton;
	import fr.skolian.view.tools.ui.SearchButton;
	import fr.skolian.view.tools.ui.TreeButton;
	
	import mx.core.UIComponent;
	
	import spark.components.Button;
	
	
/*Skolian - Content management system for primary school - Copyright (c) 2011 - Olivier Gianotti - This file is part of Skolian. Skolian is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Skolian is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Skolian.  If not, see <http://www.gnu.org/licenses/>.
contact : ogianotti@gmail.com 

Skolian - Application de gestion de contenus pédagogiques en école primaire. Copyright (C) 2011 - Olivier Gianotti - Ce fichier est une partie de Skolian. Skolian est un logiciel libre ; vous pouvez le redistribuer et/ou le modifier au titre des clauses de la Licence Publique Générale GNU, telle que publiée par la Free Software Foundation ; soit la version 2 de la Licence, ou (à votre discrétion) une version ultérieure quelconque. Ce programme est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ; sans même une garantie implicite de COMMERCIABILITE ou DE CONFORMITE A UNE UTILISATION PARTICULIERE. Voir la Licence Publique Générale GNU pour plus de détails. Vous devriez avoir reçu un exemplaire de la Licence Publique Générale GNU avec ce programme ; si ce n'est pas le cas, consultez <http://www.gnu.org/licenses/>.
contact : ogianotti@gmail.com 
*/

public class ToolBar extends UIComponent
	{
		public static const OPEN:String = "open";
		public static const CLOSE:String = "close";
		
		private var _mask:Shape;
		private var _content:Sprite;
		private var _capture:ScreenShotButton;
		private var _showTree:TreeButton;
		private var _search:SearchButton;
		private var _other:OtherButton;
		
		private var _state:String;
		
		private var _close:Button;
		
		public function ToolBar()
		{
			super();
			build();
			_state = CLOSE;
		}
		
		private function build():void{
			_content = new Sprite();
			_content.graphics.beginFill(0xffffff,.9);
			_content.graphics.drawRoundRectComplex(0,0,350,55,20,20,20,20);
			_content.graphics.endFill();
			_content.x = -350;
			addChild(_content);
			_content.filters = [new DropShadowFilter(0,45,0,.5,10,10,1)];
			
			_capture = new ScreenShotButton();
			_content.addChild(_capture);
			_capture.x = 100;
			_capture.y = 30;
			
			_showTree = new TreeButton();
			_content.addChild(_showTree);
			_showTree.x = 150;
			_showTree.y = 30;
			
			_search = new SearchButton();
			_content.addChild(_search);
			_search.x = 200;
			_search.y = 30;
			
			_other = new OtherButton();
			_content.addChild(_other);
			_other.x = 250;
			_other.y = 30;
			
			
			_mask = new Shape();
			_mask.graphics.beginFill(0xFFCC00);
			_mask.graphics.drawRoundRectComplex(0,0,350,55,20,20,20,20);
			_mask.graphics.endFill();
			_mask.scale9Grid = new Rectangle(20,20,310,15);
			addChild(_mask);
			_content.mask = _mask;
		}
		
		private function show():void{
			TweenMax.to(_content,.5,{x:0});
		}
		
		private function hide():void{
			TweenMax.to(_content,.5,{x:-350});
			
		}
		
		public function switchState():void{
			state = _state == OPEN ? CLOSE:OPEN;
		}
		
		public function set state(value:String):void{
			if(_state == value)return;
			_state = value;
			switch(value){
				case OPEN:
					show();
					break;
				case CLOSE:
					hide();
					break;
			}
		}

		public function get state():String
		{
			return _state;
		}

	}
}